{include file=head.html}

<!-- 位置 -->
<div class="pos">{pboot:position separator=' > '}</div>

<div class="msg">
    <form class="book" onsubmit="return submsg(this);">
        <ul>
            <li class="cl">
                <label>姓名</label>
                <input type="text" name="contacts" required id="contacts" placeholder="请输入联系人">
            </li>

            <li class="cl">
                <label>手机</label>
                <input type="text" name="mobile" required id="mobile" placeholder="请输入联系人手机">
            </li>

            <li class="cl">
                <label>留言</label>
                <textarea name="content" id="content" required placeholder="请输入留言内容"></textarea>
            </li>

            {pboot:if({pboot:msgcodestatus})}
            <li class="cl">
                <label>验证码</label>
                <input type="text" name="checkcode" required id="checkcode" placeholder="请输入验证码" style="width:120px;">
                <img title="点击刷新" src="{pboot:checkcode}" height="40" onclick="this.src='{pboot:checkcode}?'+Math.round(Math.random()*10);" />
            </li>
            {/pboot:if}

            <div>
                <input type="submit" value="提交">
            </div>
        </ul>
    </form>
  </div>

{include file=foot.html}

<script>
//ajax提交留言
function submsg(obj){
  var url='{pboot:msgaction}';
  var contacts=$(obj).find("#contacts").val();
  var mobile=$(obj).find("#mobile").val();
  var content=$(obj).find("#content").val();
  var checkcode=$(obj).find("#checkcode").val();

  $.ajax({
    type: 'POST',
    url: url,
    dataType: 'json',
    data: {
      contacts: contacts,
      mobile: mobile,
      content: content,
      checkcode: checkcode
    },
    success: function (response, status) {
      if(response.code) {
        alert("谢谢您的反馈，我们会尽快联系您！");
        location.href = '/'; 
      } else { 
        if(response.tourl != ""){
          if(confirm(response.data+'是否立即跳转登录？')){ location.href=response.tourl; }
        }
        $('.codeimg').click();  //更新验证码
      }
    },
    error: function(xhr, status, error){ alert('返回数据异常！'); }
  });
  return false;
}
</script>